﻿using FB.Data;
using FB.Enums;
using FB.Providers.AEInfo;
//using FB.Data.Models;
using FB.Providers.EmployeeInfo;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace FB.Providers
{
    public class EFAEInfoProvider : AEInfoProvider
    {
        string _ConnString = string.Empty;
        AEDbContext _db = null;

        public string connectionStringName { get; set; }


        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);

            #region initialize custom attributes

            this.connectionStringName = config["connectionStringName"];

            #endregion

            if (string.IsNullOrEmpty(this.connectionStringName))
                throw new ConfigurationErrorsException("connectionStringName must be set to the appropriate value");

            if (ConfigurationManager.ConnectionStrings[this.connectionStringName] == null)
                throw new ConfigurationErrorsException("connection string not found.");

            _ConnString = ConfigurationManager.ConnectionStrings[this.connectionStringName].ConnectionString;
        }


        public AEInfoUnit AEInfoUnit()
        {
            return new AEInfoUnit(new AEDbContext(this._ConnString));
        }

    }
}
